package com.lee.controller;

import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author liyacai
 * @description
 * @data 2020-05-08
 */
@RestController
@RequestMapping("/provider")
public class ProviderController {

    @GetMapping("/list")
    @HystrixCommand(fallbackMethod = "processHystrixList")
    public String list(){
        // 随机抛异常
        if(System.currentTimeMillis()%10 > 5) {
            throw new RuntimeException("随机抛异常");
        }
        return "提供者供应数据8004";
    }

    public String processHystrixList(){
        return "提供者供应数据8004 没有对应的信息";
    }
}
